home *** CD-ROM | disk | FTP | other *** search
- ;*************************************
- ;* P I C T U R E M A N A G E R *
- ;*************************************
-
- INCLUDE Library.Txt
-
- ;--------------------------------
- ; *** Externals Definition ***
- ;--------------------------------
-
- XDEF InstalPict
- XDEF DrawPicts
- XDEF FindPict
-
- ;-------------------------------
- ; ****** Picture Record ******
- ;-------------------------------
-
- ; Picture = Record { 10 bytes}
- ;{ 0} picSize : INTEGER
- ;{ 2} picFrame : Rect
-
- ;-------------------------------
- ;****** Pic Aux Record ********
- ;-------------------------------
-
- ;AuxPicRec = Record {16}
- ;{0} PID :INTEGER
- ;{2} thePic :PicHandle
- ;{6} nextPic :AuxPicHandle
- ;{10} tMode :INTEGER
- ;{12} destRect :Rect
-
- ;---------------------------------------------------------------------------
- ;FUNCTION InstalPict(PicID:INTEGER;whichWindow:WindowPtr):OSErr;
- ;---------------------------------------------------------------------------
-
- ;-------------------------------
- ; Parameters
- ;-------------------------------
-
- whichWindow EQU 8
- PicID EQU 12
-
- ;-------------------------------
- ; Local Variables
- ;-------------------------------
-
- theHandle EQU -10
- theNPict EQU -6
- error EQU -2
-
- ;-------------------------------
-
- InstalPict
- LINK A6,#-10 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVE.W #noErr,error(A6) ;
- SUBQ.L #4,SP ;place for PicHdl
- MOVE.W PicID(A6),-(SP) ;pic ID
- _GetPicture ;read it...
- MOVE.L (SP)+,A3 ;
- SUBQ.L #2,SP ;
- _ResError ;
- MOVE.W (SP)+,error(A6) ;
- BNE @0 ;if error :go @0
- MOVE.L A3,-(SP) ;now, we detach our
- _DetachResource ;pic resource from the
- SUBQ.L #2,SP ;resource list
- _ResError ;if an error occurs
- MOVE.W (SP)+,error(A6) ;we report it
- BNE @0 ;and we abort.
- MOVE.L A3,theNPict(A6) ;
- MOVE.L whichWindow(A6),A0 ;
- MOVE.L WrefCon(A0),A0 ;
- MOVE.L (A0),A0 ;we find the pict
- MOVE.L WPic(A0),A2 ;list for this window
- MOVEA.L (A2),A3 ;
- CMPI.L #NIL,thePic(A3) ;no pict , go @1
- BEQ @1 ;
-
- @3
- CMPI.L #NIL,nextPic(A3) ;
- BEQ @2 ;we must find
- MOVEA.L nextPic(A3),A3 ;the last pic AuxRec
- MOVEA.L (A3),A3 ;of the list
- BRA @3 ;
- @2
- MOVEQ #SizePicAuxRec,D0 ;
- _NewHandle ;create a new
- MOVE.W D0,error(A6) ;pic AuxRec
- BNE @0 ;
- MOVE.L A0,nextPic(A3) ;
- MOVEA.L A0,A3 ;
- MOVEA.L (A3),A3 ;
- MOVE.W picID(A6),PID(A3);
- MOVE.L theNPict(A6),thePic(A3);
- MOVE.L theNPict(A6),A0 ;
- MOVE.L (A0),A0 ;
- MOVE.L picFrame(A0),destRect(A3);
- MOVE.L picFrame+4(A0),destRect+4(A3);
- MOVE.L #NIL,nextPic(A3) ;
- CLR.W tMode(A3) ;
- BRA @0
- @1
- MOVE.W picID(A6),PID(A3);pic AuxRec already exists
- MOVE.L theNPict(A6),thePic(A3);
- MOVE.L theNPict(A6),A0 ;we initialize its fields
- MOVE.L (A0),A0 ;
- MOVE.L picFrame(A0),destRect(A3);
- MOVE.L picFrame+4(A0),destRect+4(A3);
- MOVE.L #NIL,nextPic(A3);
- CLR.W tMode(A3) ;
- @0
- MOVE.W error(A6),D0 ;
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVE.L (SP)+,A1 ;
- ADD.L #6,SP ;
- MOVE.W D0,(SP) ;
- JMP(A1) ;
-
- ;---------------------------------------------------------------------------
- ;PROCEDURE DrawPicts(whichWindow:WindowPtr);
- ;---------------------------------------------------------------------------
-
- ;-------------------------------
- ; local variables
- ;-------------------------------
-
- AuxPicHdl EQU -4
-
- ;-------------------------------
-
- DrawPicts
- LINK A6,#-4 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVE.L whichWindow(A6),A0 ;
- MOVE.L WrefCon(A0),A0 ;
- MOVE.L (A0),A0 ;
- MOVE.L WPic(A0),A3 ;the first
- MOVE.L A3,AuxPicHdl(A6) ;pic AuxRec
- MOVE.L (A3),A3 ;for this window
- CMPI.L #NIL,thePic(A3) ;no pict for this
- BEQ @0 ;window, go @0
- @3
- MOVE.W tMode(A3),-(SP) ;
- _PenMode ;we set the pen mode
- MOVE.L AuxPicHdl(A6),A3 ;before drawing
- MOVE.L (A3),A3 ;
- MOVE.L thePic(A3),-(SP) ;
- PEA destRect(A3) ;
- _DrawPicture ;
- _PenNormal ;
- MOVE.L AuxPicHdl(A6),A3 ;
- MOVE.L (A3),A3 ;
- CMPI.L #NIL,nextPic(A3) ;another pict to draw
- BEQ @0 ;no so go @0
- MOVEA.L nextPic(A3),A3 ;
- MOVE.L A3,AuxPicHdl(A6) ;
- MOVEA.L (A3),A3 ;
- BRA @3 ;
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVE.L (SP)+,A0 ;
- ADD.L #4,SP ;
- JMP (A0) ;
-
- ;---------------------------------------------------------------------------
- ;FUNCTION FindPict(thePoint:Point;whichWindow:WindowPtr):PicHandle;
- ;---------------------------------------------------------------------------
-
- ;-------------------------------
- ; Parameters
- ;-------------------------------
-
- thePoint EQU 12
-
- ;-------------------------------
- ; Local Variables
- ;-------------------------------
-
- theFPic EQU -4
-
- ;-------------------------------
-
- FindPict
- LINK A6,#-4 ;
- MOVEM.L A2-A4/D3-D7,-(SP) ;
- MOVE.L #NIL,A1 ;
- MOVE.L whichWindow(A6),A0 ;
- MOVE.L WrefCon(A0),A0 ;
- MOVE.L (A0),A0 ;
- MOVE.L WPic(A0),A3 ;
- MOVEA.L (A3),A3 ;
- CMPI.L #NIL,thePic(A3) ;
- BEQ @0 ;
- @3
- MOVE.L thePic(A3),A0 ;
- MOVE.L A0,theFPic(A6) ;
- SUBQ.L #2,SP ;
- MOVE.L thePoint(A6),-(SP) ;
- PEA destRect(A3) ;do we cliked
- _PtInRect ;in this pict ?
- TST.B (SP)+ ;
- BNE @1 ;yes, so go @1
- CMPI.L #NIL,nextPic(A3) ;no, next pict
- BEQ @0 ;in the (if any)
- MOVEA.L nextPic(A3),A3 ;if not, go @0
- MOVEA.L (A3),A3 ;
- BRA @3 ;
- @1
- MOVE.L theFPic(A6),A1 ;we've found it
- @0
- MOVEM.L (SP)+,A2-A4/D3-D7 ;
- UNLK A6 ;
- MOVE.L (SP)+,A0 ;
- ADD.L #8,SP ;
- MOVE.L A1,(SP) ;
- JMP (A0) ;
-
- END